package com.android.baselibrary.base

import android.os.Bundle
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.alibaba.android.arouter.launcher.ARouter

/**
 * @author: Mr.You
 * @create: 2023-11-24 17:08
 * @description:
 **/
abstract class BaseDBActivity<DB : ViewDataBinding>(@LayoutRes val layoutId: Int = 0) :
    AppCompatActivity() {
     lateinit var mBinding: DB
    private var mLayoutId = layoutId
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (layoutId == 0) {
            mLayoutId = getActivityLayoutId()
        }

        mBinding = DataBindingUtil.setContentView(this, mLayoutId)
        ARouter.getInstance().inject(this)
        initView()
        initVMData()
    }

    abstract fun initView()

    abstract fun initVMData()

    open fun getActivityLayoutId():Int {
        return 0
    }
}